/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.objects;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Housing object
 * @author Kyle Parker, University Computing Services
 */
public class Housing implements Comparable<Housing> {
	private String complexDesc;
	private String complexFeatures;
	private String complexName;
	private String contractType;
	private String error;
	private String floorCode;
	private String floorDesc;
	private String hallCode;
	private String hallDesc;
	private String hallGroupDesc;
	private String housingType;
	private URL imageURL;
	private String latitude;
	private String livingLearning;
	private String longitude;
	private String mealPlan;
	private String rate;
	private String roomDesc;
	private String roomID;
	private String roomNumber;

	public String getComplexDesc() {		
		return complexDesc;
	}
	public void setComplexDesc(String value) {
		this.complexDesc = value.trim();
	}
	
	public String getComplexFeatures() {		
		return complexFeatures;
	}
	public void setComplexFeatures(String value) {
		this.complexFeatures = value.trim();
	}
	
	public String getComplexName() {		
		return complexName;
	}
	public void setComplexName(String value) {
		this.complexName = value.trim();
	}

	public String getContractType() {
		return contractType;
	}
	public void setContractType(String value) {
		this.contractType = value.trim();
	}
	
	public String getError() {		
		return error;
	}
	public void setError(String value) {
		this.error = value.trim();
	}
	
	public String getFloorCode() {		
		return floorCode;
	}
	public void setFloorCode(String value) {
		this.floorCode = value.trim();
	}
	
	public String getFloorDesc() {		
		return floorDesc;
	}
	public void setFloorDesc(String value) {
		this.floorDesc = value.trim();
	}
	
	public String getHallCode() {		
		return hallCode;
	}
	public void setHallCode(String value) {
		this.hallCode = value.trim();
	}

	public String getHallDesc() {
		return hallDesc;
	}
	public void setHallDesc(String value) {
		this.hallDesc = value.trim();
	}

	public String getHallGroupDesc() {		
		return hallGroupDesc;
	}
	public void setHallGroupDesc(String value) {
		this.hallGroupDesc = value.trim();
	}

	public String getHousingType() {		
		return housingType;
	}
	public void setHousingType(String value) {
		this.housingType = value.trim();
	}
	
	public URL getImageURL() {
		return imageURL;
	}	
	public void setImageURL(String value) {
		try {
			this.imageURL = new URL(value);
		} catch (MalformedURLException e) {
			this.imageURL = null;
		}
	}

	public String getLatitude() {		
		return latitude;
	}
	public void setLatitude(String value) {
		this.latitude = value.trim();
	}
	
	public String getLivingLearning() {		
		return livingLearning;
	}
	public void setLivingLearning(String value) {
		this.livingLearning = value.trim();
	}
	
	public String getLongitude() {		
		return longitude;
	}
	public void setLongitude(String value) {
		this.longitude = value.trim();
	}

	public String getMealPlan() {
		return mealPlan;
	}
	public void setMealPlan(String value) {
		this.mealPlan = value.trim();
	}
	
	public String getRate() {
		return rate;
	}
	public void setRate(String value)  {
		this.rate = value.trim();
	}
	
	public String getRoomDesc() {
		return roomDesc;
	}
	public void setRoomDesc(String value) {
		this.roomDesc = value.trim();
	}

	public String getRoomID() {
		return this.roomID;
	}
	public void setRoomID(String value)  {
		this.roomID = value;
	}

	public String getRoomNumber() {
		return this.roomNumber;
	}
	public void setRoomNumber(String value) {
		this.roomNumber = value;
	}
	
	public Housing copy() {
		Housing copy = new Housing();
		copy.complexDesc = complexDesc;
		copy.complexFeatures = complexFeatures;
		copy.complexName = complexName;
		copy.contractType = contractType;
		copy.error = error;
		copy.floorCode = floorCode;
		copy.floorDesc = floorDesc;
		copy.hallCode = hallCode;
		copy.hallDesc = hallDesc;
		copy.hallGroupDesc = hallGroupDesc;
		copy.housingType = housingType;
		copy.imageURL = imageURL;
		copy.latitude = latitude;
		copy.livingLearning = livingLearning;
		copy.longitude = longitude;
		copy.mealPlan = mealPlan;
		copy.rate = rate;
		copy.roomDesc = roomDesc;
		copy.roomID = roomID;
		copy.roomNumber = roomNumber;
		return copy;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((complexDesc == null) ? 0 : complexDesc.hashCode());
		result = prime * result + ((complexFeatures == null) ? 0 : complexFeatures.hashCode());
		result = prime * result + ((complexName == null) ? 0 : complexName.hashCode());
		result = prime * result + ((contractType == null) ? 0 : contractType.hashCode());
		result = prime * result + ((error == null) ? 0 : error.hashCode());
		result = prime * result + ((floorCode == null) ? 0 : floorCode.hashCode());
		result = prime * result + ((floorDesc == null) ? 0 : floorDesc.hashCode());
		result = prime * result + ((hallCode == null) ? 0 : hallCode.hashCode());
		result = prime * result + ((hallDesc == null) ? 0 : hallDesc.hashCode());
		result = prime * result + ((hallGroupDesc == null) ? 0 : hallGroupDesc.hashCode());
		result = prime * result + ((housingType == null) ? 0 : housingType.hashCode());
		result = prime * result + ((imageURL == null) ? 0 : imageURL.hashCode());
		result = prime * result + ((latitude == null) ? 0 : latitude.hashCode());
		result = prime * result + ((livingLearning == null) ? 0 : livingLearning.hashCode());
		result = prime * result + ((longitude == null) ? 0 : longitude.hashCode());
		result = prime * result + ((mealPlan == null) ? 0 : mealPlan.hashCode());
		result = prime * result + ((rate == null) ? 0 : rate.hashCode());
		result = prime * result + ((roomDesc == null) ? 0 : roomDesc.hashCode());
		result = prime * result + ((roomID == null) ? 0 : roomID.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) { return true; }
		
		if (obj == null) { return false; }
		
		if (getClass() != obj.getClass()) { return false; }
		
		Housing other = (Housing) obj;

		if (complexDesc == null)  {
			if (other.complexDesc != null) { return false; }
		} else if (!complexDesc.equals(other.complexDesc)) { return false; }
		
		if (complexFeatures == null)  {
			if (other.complexFeatures != null) { return false; }
		} else if (!complexFeatures.equals(other.complexFeatures)) { return false; }
		
		if (complexName == null)  {
			if (other.complexName != null) { return false; }
		} else if (!complexName.equals(other.complexName)) { return false; }
		
		if (contractType == null) {
			if (other.contractType != null) { return false; }
		} else if (!contractType.equals(other.contractType)) { return false; }
		
		if (error == null) {
			if (other.error != null) { return false; }
		} else if (!error.equals(other.error)) { return false; }
		
		if (floorCode == null) {
			if (other.floorCode != null) { return false; }
		} else if (!floorCode.equals(other.floorCode)) { return false; }
		
		if (floorDesc == null) {
			if (other.floorDesc != null) { return false; }
		} else if (!floorDesc.equals(other.floorDesc)) { return false; }
		
		if (hallCode == null) {
			if (other.hallCode != null) { return false; }
		} else if (!hallCode.equals(other.hallCode)) { return false; }
		
		if (hallDesc == null) {
			if (other.hallDesc != null) { return false; }
		} else if (!hallDesc.equals(other.hallDesc)) { return false; }
		
		if (hallGroupDesc == null) {
			if (other.hallGroupDesc != null) { return false; }
		}  else if (!hallGroupDesc.equals(other.hallGroupDesc)) { return false; }
		
		if (housingType == null) {
			if (other.housingType != null) { return false; }
		}  else if (!housingType.equals(other.housingType)) { return false; }
		
		if (imageURL == null) {
			if (other.imageURL != null) { return false; }
		}  else if (!imageURL.equals(other.imageURL)) { return false; }
		
		if (latitude == null) {
			if (other.latitude != null) { return false; }
		} else if (!latitude.equals(other.latitude)) { return false; }
		
		if (livingLearning == null) {
			if (other.livingLearning != null) { return false; }
		} else if (!livingLearning.equals(other.livingLearning)) { return false; }
		
		if (longitude == null)  {
			if (other.longitude != null) { return false; }
		} else if (!longitude.equals(other.longitude)) { return false; }
		
		if (mealPlan == null) {
			if (other.mealPlan != null) { return false; }
		}  else if (!mealPlan.equals(other.mealPlan)) { return false; }
		
		if (rate == null) {
			if (other.rate != null) { return false; }
		} else if (!rate.equals(other.rate)) { return false; }
		
		if (roomDesc == null) {
			if (other.roomDesc != null) { return false; }
		} else if (!roomDesc.equals(other.roomDesc)) { return false; }
		
		if (roomID == null) {
			if (other.roomID != null) { return false; }
		}  else if (!roomID.equals(other.roomID)) { return false; }
		
		if (roomNumber == null) {
			if (other.roomNumber != null) { return false; }
		} else if (!roomNumber.equals(other.roomNumber)) { return false; }
		
		return true;
	}

	public int compareTo(Housing another)  {
		if (another == null) return 1; 
		return another.hallCode.compareTo(hallCode);
	}
}
